package ThreadDemo;

/**
 * 不带返回值的线程
 */
public class ThreadDemo15 {

    static class result{
        public static int sum;
    }


    public static void main(String[] args) throws InterruptedException {
        Object locker=new Object();
        Thread thread=new Thread(new Runnable() {
            @Override
            public void run() {
                int sum=0;
                for (int i = 0; i < 10; i++) {
                    sum+=i;
                }
                result.sum=sum;
                synchronized (locker){
                    locker.notify();
                }
            }

        });

        thread.start();
        while (result.sum==0){
            synchronized (locker){
                locker.wait();
            }
        }
        System.out.println(result.sum);
    }
}
